package com.ken.android.music.view;

import android.app.Application;
import android.content.Context;

import com.ken.android.music.db.MusicDao;
import com.ken.android.music.data.MySharedPre;

import org.xutils.BuildConfig;
import org.xutils.x;

/**
 * Created by axnshy on 16/8/5.
 */
public class MyApplication extends Application {

    private static Application mApplication;

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        mApplication = this;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        x.Ext.init(this);
        x.Ext.setDebug(BuildConfig.DEBUG);
        if (MySharedPre.getOpenFlag(this)==0) {
            scanLocal();
            MySharedPre.setOpenFLAG(this);
        }
    }

    /*
   * 扫描本地音乐文件
   * */
    private void scanLocal() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                MusicDao.get().scanMusic(getApplicationContext());
            }
        }).start();

    }

    public static Application getApplication(){
        return mApplication;
    }

}
